package com.java.jvm.demo.chapter02;

/**
 * @author wangning
 * @create 2021-11-11 10:16
 * 通过-Xss参数可以设置栈空间的大小，从而控制函数的调用深度
 */
public class StackDeepTest {

	public static int count = 0;

	public static void recursion() {
		count++;
		recursion();
	}

	public static void main(String[] args) {
		try {
			recursion();
		} catch (Throwable e) {//注：这里是Error，不能用Exception,需要使用Throwable
			System.out.println("deep of calling: " + count);
			e.printStackTrace();
		}
	}
}
